package com.locatme.adapter;


import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.main.locatme.R;

public class SenderViewAdapter extends ArrayAdapter<String>{
    private List<String> entries;
    private Activity activity;

    public SenderViewAdapter(Activity a, int textViewResourceId, List<String> senders) {
        super(a, textViewResourceId, senders);
        this.setEntries(senders);
        this.activity = a;
    }

    public static class ViewHolder{
        private TextView item1;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        ViewHolder holder;
        if (v == null) {
            LayoutInflater vi =
                    (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.fragment_onesender, null);
            holder = new ViewHolder();
            holder.item1 = (TextView) v.findViewById(R.id.namefrom);
            v.setTag(holder);
        }
        else{
            holder=(ViewHolder)v.getTag();
        }

        final String sender = getEntries().get(position);
        if (sender != null) {
            holder.item1.setTypeface(null,Typeface.BOLD);
            holder.item1.setText(sender);

        }
        return v;
    }

    private List<String> getEntries() {
        return entries;
    }

    private void setEntries(List<String> entries) {
        this.entries = entries;
    }

}
